package logic.nodes.collision;

import sound.AudioManager;
import logic.nodes.lod.LODNode;

import com.jme.bounding.BoundingVolume;

public class HullCollision extends Collision {
	
	public HullCollision(CollidableNode a, CollidableNode b) {
		super(a, b);
	}
	
	@Override
	protected void computeLocations() {
		BoundingVolume volumeA = getVolume(a, b);
		if(volumeA == null) return;
		BoundingVolume volumeB = getVolume(b, a);
		if(volumeB == null) return;
		
		aToB = volumeB.getCenter().subtract(volumeA.getCenter()).normalize();
	}
	
	protected BoundingVolume getVolume(CollidableNode node, CollidableNode other) {
		if(node.isLarge()) {
			assert(node instanceof LODNode);
			
			return getCollisionPoint(other, (LODNode)node);
		}
		
		return node.getBound();
	}
	
	@Override
	protected String getCollisionSound() { return AudioManager.COLLISION_02; }
}